<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - ged.info - gil/color_base.hpp</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../index.html">directory</a> - <a href="index.html">gil</a> - color_base.hpp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>ged.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2009-06-09</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">9</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">100.0 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">9</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : /*
<span class="lineNum">       2 </span>                :     Copyright 2005-2007 Adobe Systems Incorporated
<span class="lineNum">       3 </span>                :    
<span class="lineNum">       4 </span>                :     Use, modification and distribution are subject to the Boost Software License,
<span class="lineNum">       5 </span>                :     Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
<span class="lineNum">       6 </span>                :     http://www.boost.org/LICENSE_1_0.txt).
<span class="lineNum">       7 </span>                : 
<span class="lineNum">       8 </span>                :     See http://stlab.adobe.com/gil for most recent version including documentation.
<span class="lineNum">       9 </span>                : */
<span class="lineNum">      10 </span>                : 
<span class="lineNum">      11 </span>                : /*************************************************************************************************/
<span class="lineNum">      12 </span>                : 
<span class="lineNum">      13 </span>                : #ifndef GIL_COLOR_BASE_HPP
<span class="lineNum">      14 </span>                : #define GIL_COLOR_BASE_HPP
<span class="lineNum">      15 </span>                : 
<span class="lineNum">      16 </span>                : ////////////////////////////////////////////////////////////////////////////////////////
<span class="lineNum">      17 </span>                : /// \file               
<span class="lineNum">      18 </span>                : /// \brief pixel class and related utilities
<span class="lineNum">      19 </span>                : /// \author Lubomir Bourdev and Hailin Jin \n
<span class="lineNum">      20 </span>                : ///         Adobe Systems Incorporated
<span class="lineNum">      21 </span>                : /// \date   2005-2007 \n Last updated on May 6, 2007
<span class="lineNum">      22 </span>                : ///
<span class="lineNum">      23 </span>                : ////////////////////////////////////////////////////////////////////////////////////////
<span class="lineNum">      24 </span>                : 
<span class="lineNum">      25 </span>                : #include &lt;cassert&gt;
<span class="lineNum">      26 </span>                : #include &lt;boost/mpl/range_c.hpp&gt;
<span class="lineNum">      27 </span>                : #include &lt;boost/mpl/size.hpp&gt;
<span class="lineNum">      28 </span>                : #include &lt;boost/mpl/vector_c.hpp&gt;
<span class="lineNum">      29 </span>                : #include &lt;boost/type_traits.hpp&gt;
<span class="lineNum">      30 </span>                : #include &lt;boost/utility/enable_if.hpp&gt;
<span class="lineNum">      31 </span>                : 
<span class="lineNum">      32 </span>                : #include &quot;gil_config.hpp&quot;
<span class="lineNum">      33 </span>                : #include &quot;utilities.hpp&quot;
<span class="lineNum">      34 </span>                : #include &quot;gil_concept.hpp&quot;
<span class="lineNum">      35 </span>                : 
<span class="lineNum">      36 </span>                : namespace boost { namespace gil {
<span class="lineNum">      37 </span>                : 
<span class="lineNum">      38 </span>                : // Forward-declare
<span class="lineNum">      39 </span>                : template &lt;typename P&gt; P* memunit_advanced(const P* p, std::ptrdiff_t diff);
<span class="lineNum">      40 </span>                : 
<span class="lineNum">      41 </span>                : // Forward-declare semantic_at_c
<span class="lineNum">      42 </span>                : template &lt;int K, typename ColorBase&gt;
<span class="lineNum">      43 </span>                : typename disable_if&lt;is_const&lt;ColorBase&gt;,typename kth_semantic_element_reference_type&lt;ColorBase,K&gt;::type&gt;::type semantic_at_c(ColorBase&amp; p);
<span class="lineNum">      44 </span>                : template &lt;int K, typename ColorBase&gt;
<span class="lineNum">      45 </span>                : typename kth_semantic_element_const_reference_type&lt;ColorBase,K&gt;::type semantic_at_c(const ColorBase&amp; p);
<span class="lineNum">      46 </span>                : 
<span class="lineNum">      47 </span>                : // Forward declare element_reference_type
<span class="lineNum">      48 </span>                : template &lt;typename ColorBase&gt; struct element_reference_type;
<span class="lineNum">      49 </span>                : template &lt;typename ColorBase&gt; struct element_const_reference_type;
<span class="lineNum">      50 </span>                : template &lt;typename ColorBase, int K&gt; struct kth_element_type;
<span class="lineNum">      51 </span>                : template &lt;typename ColorBase, int K&gt; struct kth_element_type&lt;const ColorBase,K&gt; : public kth_element_type&lt;ColorBase,K&gt; {};
<span class="lineNum">      52 </span>                : template &lt;typename ColorBase, int K&gt; struct kth_element_reference_type;
<span class="lineNum">      53 </span>                : template &lt;typename ColorBase, int K&gt; struct kth_element_reference_type&lt;const ColorBase,K&gt; : public kth_element_reference_type&lt;ColorBase,K&gt; {};
<span class="lineNum">      54 </span>                : template &lt;typename ColorBase, int K&gt; struct kth_element_const_reference_type;
<span class="lineNum">      55 </span>                : template &lt;typename ColorBase, int K&gt; struct kth_element_const_reference_type&lt;const ColorBase,K&gt; : public kth_element_const_reference_type&lt;ColorBase,K&gt; {};
<span class="lineNum">      56 </span>                : 
<span class="lineNum">      57 </span>                : namespace detail {
<span class="lineNum">      58 </span>                : 
<span class="lineNum">      59 </span>                : template &lt;typename DstLayout, typename SrcLayout, int K&gt;
<span class="lineNum">      60 </span>                : struct mapping_transform 
<span class="lineNum">      61 </span>                :     : public mpl::at&lt;typename SrcLayout::channel_mapping_t, 
<span class="lineNum">      62 </span>                :                      typename detail::type_to_index&lt;typename DstLayout::channel_mapping_t,mpl::integral_c&lt;int,K&gt; &gt;::type
<span class="lineNum">      63 </span>                :                            &gt;::type {};
<span class="lineNum">      64 </span>                : 
<span class="lineNum">      65 </span>                : /// \defgroup ColorBaseModelHomogeneous detail::homogeneous_color_base 
<span class="lineNum">      66 </span>                : /// \ingroup ColorBaseModel
<span class="lineNum">      67 </span>                : /// \brief A homogeneous color base holding one color element. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept
<span class="lineNum">      68 </span>                : /// If the element type models Regular, this class models HomogeneousColorBaseValueConcept.
<span class="lineNum">      69 </span>                : 
<span class="lineNum">      70 </span>                : 
<span class="lineNum">      71 </span>                : /// \brief A homogeneous color base holding one color element. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept
<span class="lineNum">      72 </span>                : /// \ingroup ColorBaseModelHomogeneous
<span class="lineNum">      73 </span>                : template &lt;typename Element, typename Layout&gt;
<span class="lineNum">      74 </span>                : struct homogeneous_color_base&lt;Element,Layout,1&gt; {
<span class="lineNum">      75 </span>                : private:
<span class="lineNum">      76 </span>                :     Element _v0;
<span class="lineNum">      77 </span>                : public:
<span class="lineNum">      78 </span>                :     typedef Layout layout_t;
<span class="lineNum">      79 </span>                :     typename element_reference_type&lt;homogeneous_color_base&gt;::type       at(mpl::int_&lt;0&gt;)       { return _v0; }
<span class="lineNum">      80 </span>                :     typename element_const_reference_type&lt;homogeneous_color_base&gt;::type at(mpl::int_&lt;0&gt;) const { return _v0; }
<span class="lineNum">      81 </span>                : 
<span class="lineNum">      82 </span>                :     homogeneous_color_base() {}
<span class="lineNum">      83 </span>                :     homogeneous_color_base(Element v) : _v0(v) {}
<span class="lineNum">      84 </span>                :  
<span class="lineNum">      85 </span>                :     // grayscale pixel values are convertible to channel type
<span class="lineNum">      86 </span>                :     operator Element () const { return _v0; }
<span class="lineNum">      87 </span>                : 
<span class="lineNum">      88 </span>                :     template &lt;typename E2, typename L2&gt; homogeneous_color_base(const homogeneous_color_base&lt;E2,L2,1&gt;&amp; c) : _v0(at_c&lt;0&gt;(c)) {}
<span class="lineNum">      89 </span>                : };
<span class="lineNum">      90 </span>                : 
<span class="lineNum">      91 </span>                : 
<span class="lineNum">      92 </span>                : /// \brief A homogeneous color base holding two color elements. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept
<span class="lineNum">      93 </span>                : /// \ingroup ColorBaseModelHomogeneous
<span class="lineNum">      94 </span>                : template &lt;typename Element, typename Layout&gt;
<span class="lineNum">      95 </span>                : struct homogeneous_color_base&lt;Element,Layout,2&gt; {
<span class="lineNum">      96 </span>                : private:
<span class="lineNum">      97 </span>                :     Element _v0, _v1;
<span class="lineNum">      98 </span>                : public:
<span class="lineNum">      99 </span>                :     typedef Layout layout_t;
<span class="lineNum">     100 </span>                :     typename element_reference_type&lt;homogeneous_color_base&gt;::type       at(mpl::int_&lt;0&gt;)       { return _v0; }
<span class="lineNum">     101 </span>                :     typename element_const_reference_type&lt;homogeneous_color_base&gt;::type at(mpl::int_&lt;0&gt;) const { return _v0; }
<span class="lineNum">     102 </span>                :     typename element_reference_type&lt;homogeneous_color_base&gt;::type       at(mpl::int_&lt;1&gt;)       { return _v1; }
<span class="lineNum">     103 </span>                :     typename element_const_reference_type&lt;homogeneous_color_base&gt;::type at(mpl::int_&lt;1&gt;) const { return _v1; }
<span class="lineNum">     104 </span>                : 
<span class="lineNum">     105 </span>                :     homogeneous_color_base() {}
<span class="lineNum">     106 </span>                :     explicit homogeneous_color_base(Element v) : _v0(v), _v1(v) {}
<span class="lineNum">     107 </span>                :     homogeneous_color_base(Element v0, Element v1) : _v0(v0), _v1(v1) {}
<span class="lineNum">     108 </span>                : 
<span class="lineNum">     109 </span>                :     template &lt;typename E2, typename L2&gt; homogeneous_color_base(const homogeneous_color_base&lt;E2,L2,2&gt;&amp; c) : 
<span class="lineNum">     110 </span>                :         _v0(at_c&lt;mapping_transform&lt;Layout,L2,0&gt;::value&gt;(c)), 
<span class="lineNum">     111 </span>                :         _v1(at_c&lt;mapping_transform&lt;Layout,L2,1&gt;::value&gt;(c)) {}
<span class="lineNum">     112 </span>                : 
<span class="lineNum">     113 </span>                :     // Support for l-value reference proxy copy construction
<span class="lineNum">     114 </span>                :     template &lt;typename E2, typename L2&gt; homogeneous_color_base(      homogeneous_color_base&lt;E2,L2,2&gt;&amp; c) : 
<span class="lineNum">     115 </span>                :         _v0(at_c&lt;mapping_transform&lt;Layout,L2,0&gt;::value&gt;(c)), 
<span class="lineNum">     116 </span>                :         _v1(at_c&lt;mapping_transform&lt;Layout,L2,1&gt;::value&gt;(c)) {}
<span class="lineNum">     117 </span>                : 
<span class="lineNum">     118 </span>                :     // Support for planar_pixel_iterator construction and dereferencing
<span class="lineNum">     119 </span>                :     template &lt;typename P&gt; homogeneous_color_base(P* p,bool) : 
<span class="lineNum">     120 </span>                :         _v0(&amp;semantic_at_c&lt;0&gt;(*p)), 
<span class="lineNum">     121 </span>                :         _v1(&amp;semantic_at_c&lt;1&gt;(*p)) {}
<span class="lineNum">     122 </span>                :     template &lt;typename Ref&gt; Ref deref() const { 
<span class="lineNum">     123 </span>                :         return Ref(*semantic_at_c&lt;0&gt;(*this), 
<span class="lineNum">     124 </span>                :                    *semantic_at_c&lt;1&gt;(*this)); }
<span class="lineNum">     125 </span>                : 
<span class="lineNum">     126 </span>                :     // Support for planar_pixel_reference offset constructor
<span class="lineNum">     127 </span>                :     template &lt;typename Ptr&gt; homogeneous_color_base(const Ptr&amp; ptr, std::ptrdiff_t diff) 
<span class="lineNum">     128 </span>                :         : _v0(*memunit_advanced(semantic_at_c&lt;0&gt;(ptr),diff)),
<span class="lineNum">     129 </span>                :           _v1(*memunit_advanced(semantic_at_c&lt;1&gt;(ptr),diff)) {}
<span class="lineNum">     130 </span>                : 
<span class="lineNum">     131 </span>                :     // Support for planar_pixel_reference operator[]
<span class="lineNum">     132 </span>                :     Element at_c_dynamic(std::size_t i) const {
<span class="lineNum">     133 </span>                :         if (i==0) return _v0;
<span class="lineNum">     134 </span>                :         return _v1;
<span class="lineNum">     135 </span>                :     }
<span class="lineNum">     136 </span>                : };
<span class="lineNum">     137 </span>                : 
<span class="lineNum">     138 </span>                : /// \brief A homogeneous color base holding three color elements. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept
<span class="lineNum">     139 </span>                : /// \ingroup ColorBaseModelHomogeneous
<span class="lineNum">     140 </span>                : template &lt;typename Element, typename Layout&gt;
<span class="lineNum">     141 </span>                : struct homogeneous_color_base&lt;Element,Layout,3&gt; {
<span class="lineNum">     142 </span>                : private:
<span class="lineNum">     143 </span>                :     Element _v0, _v1, _v2;
<span class="lineNum">     144 </span>                : public:
<span class="lineNum">     145 </span>                :     typedef Layout layout_t;
<span class="lineNum">     146 </span><span class="lineCov">         142932 :     typename element_reference_type&lt;homogeneous_color_base&gt;::type       at(mpl::int_&lt;0&gt;)       { return _v0; }</span>
<span class="lineNum">     147 </span><span class="lineCov">         142932 :     typename element_const_reference_type&lt;homogeneous_color_base&gt;::type at(mpl::int_&lt;0&gt;) const { return _v0; }</span>
<span class="lineNum">     148 </span><span class="lineCov">         142932 :     typename element_reference_type&lt;homogeneous_color_base&gt;::type       at(mpl::int_&lt;1&gt;)       { return _v1; }</span>
<span class="lineNum">     149 </span><span class="lineCov">         142932 :     typename element_const_reference_type&lt;homogeneous_color_base&gt;::type at(mpl::int_&lt;1&gt;) const { return _v1; }</span>
<span class="lineNum">     150 </span><span class="lineCov">         142932 :     typename element_reference_type&lt;homogeneous_color_base&gt;::type       at(mpl::int_&lt;2&gt;)       { return _v2; }</span>
<span class="lineNum">     151 </span><span class="lineCov">         142932 :     typename element_const_reference_type&lt;homogeneous_color_base&gt;::type at(mpl::int_&lt;2&gt;) const { return _v2; }</span>
<span class="lineNum">     152 </span>                : 
<span class="lineNum">     153 </span><span class="lineCov">              6 :     homogeneous_color_base() {}</span>
<span class="lineNum">     154 </span>                :     explicit homogeneous_color_base(Element v) : _v0(v), _v1(v), _v2(v) {}
<span class="lineNum">     155 </span>                :     homogeneous_color_base(Element v0, Element v1, Element v2) : _v0(v0), _v1(v1), _v2(v2) {}
<span class="lineNum">     156 </span>                : 
<span class="lineNum">     157 </span>                :     template &lt;typename E2, typename L2&gt; homogeneous_color_base(const homogeneous_color_base&lt;E2,L2,3&gt;&amp; c) : 
<span class="lineNum">     158 </span>                :         _v0(at_c&lt;mapping_transform&lt;Layout,L2,0&gt;::value&gt;(c)), 
<span class="lineNum">     159 </span>                :         _v1(at_c&lt;mapping_transform&lt;Layout,L2,1&gt;::value&gt;(c)), 
<span class="lineNum">     160 </span>                :         _v2(at_c&lt;mapping_transform&lt;Layout,L2,2&gt;::value&gt;(c)) {}
<span class="lineNum">     161 </span>                : 
<span class="lineNum">     162 </span>                :     // Support for l-value reference proxy copy construction
<span class="lineNum">     163 </span>                :     template &lt;typename E2, typename L2&gt; homogeneous_color_base(      homogeneous_color_base&lt;E2,L2,3&gt;&amp; c) : 
<span class="lineNum">     164 </span>                :         _v0(at_c&lt;mapping_transform&lt;Layout,L2,0&gt;::value&gt;(c)), 
<span class="lineNum">     165 </span>                :         _v1(at_c&lt;mapping_transform&lt;Layout,L2,1&gt;::value&gt;(c)), 
<span class="lineNum">     166 </span>                :         _v2(at_c&lt;mapping_transform&lt;Layout,L2,2&gt;::value&gt;(c)) {}
<span class="lineNum">     167 </span>                : 
<span class="lineNum">     168 </span>                :     // Support for planar_pixel_iterator construction and dereferencing
<span class="lineNum">     169 </span>                :     template &lt;typename P&gt; homogeneous_color_base(P* p,bool) : 
<span class="lineNum">     170 </span>                :         _v0(&amp;semantic_at_c&lt;0&gt;(*p)), 
<span class="lineNum">     171 </span>                :         _v1(&amp;semantic_at_c&lt;1&gt;(*p)), 
<span class="lineNum">     172 </span>                :         _v2(&amp;semantic_at_c&lt;2&gt;(*p)) {}
<span class="lineNum">     173 </span>                :     template &lt;typename Ref&gt; Ref deref() const { 
<span class="lineNum">     174 </span>                :         return Ref(*semantic_at_c&lt;0&gt;(*this), 
<span class="lineNum">     175 </span>                :                    *semantic_at_c&lt;1&gt;(*this), 
<span class="lineNum">     176 </span>                :                    *semantic_at_c&lt;2&gt;(*this)); }
<span class="lineNum">     177 </span>                : 
<span class="lineNum">     178 </span>                :     // Support for planar_pixel_reference offset constructor
<span class="lineNum">     179 </span>                :     template &lt;typename Ptr&gt; homogeneous_color_base(const Ptr&amp; ptr, std::ptrdiff_t diff) 
<span class="lineNum">     180 </span>                :         : _v0(*memunit_advanced(semantic_at_c&lt;0&gt;(ptr),diff)),
<span class="lineNum">     181 </span>                :           _v1(*memunit_advanced(semantic_at_c&lt;1&gt;(ptr),diff)),
<span class="lineNum">     182 </span>                :           _v2(*memunit_advanced(semantic_at_c&lt;2&gt;(ptr),diff)) {}
<span class="lineNum">     183 </span>                : 
<span class="lineNum">     184 </span>                :     // Support for planar_pixel_reference operator[]
<span class="lineNum">     185 </span>                :         Element at_c_dynamic(std::size_t i) const {
<span class="lineNum">     186 </span>                :         switch (i) {
<span class="lineNum">     187 </span>                :             case 0: return _v0;
<span class="lineNum">     188 </span>                :             case 1: return _v1;
<span class="lineNum">     189 </span>                :         }
<span class="lineNum">     190 </span>                :         return _v2;
<span class="lineNum">     191 </span>                :     }
<span class="lineNum">     192 </span>                : };
<span class="lineNum">     193 </span>                : 
<span class="lineNum">     194 </span>                : /// \brief A homogeneous color base holding four color elements. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept
<span class="lineNum">     195 </span>                : /// \ingroup ColorBaseModelHomogeneous
<span class="lineNum">     196 </span>                : template &lt;typename Element, typename Layout&gt;
<span class="lineNum">     197 </span>                : struct homogeneous_color_base&lt;Element,Layout,4&gt; {
<span class="lineNum">     198 </span>                : private:
<span class="lineNum">     199 </span>                :     Element _v0, _v1, _v2, _v3;
<span class="lineNum">     200 </span>                : public:
<span class="lineNum">     201 </span>                :     typedef Layout layout_t;
<span class="lineNum">     202 </span>                :     typename element_reference_type&lt;homogeneous_color_base&gt;::type       at(mpl::int_&lt;0&gt;)       { return _v0; }
<span class="lineNum">     203 </span>                :     typename element_const_reference_type&lt;homogeneous_color_base&gt;::type at(mpl::int_&lt;0&gt;) const { return _v0; }
<span class="lineNum">     204 </span>                :     typename element_reference_type&lt;homogeneous_color_base&gt;::type       at(mpl::int_&lt;1&gt;)       { return _v1; }
<span class="lineNum">     205 </span>                :     typename element_const_reference_type&lt;homogeneous_color_base&gt;::type at(mpl::int_&lt;1&gt;) const { return _v1; }
<span class="lineNum">     206 </span>                :     typename element_reference_type&lt;homogeneous_color_base&gt;::type       at(mpl::int_&lt;2&gt;)       { return _v2; }
<span class="lineNum">     207 </span>                :     typename element_const_reference_type&lt;homogeneous_color_base&gt;::type at(mpl::int_&lt;2&gt;) const { return _v2; }
<span class="lineNum">     208 </span>                :     typename element_reference_type&lt;homogeneous_color_base&gt;::type       at(mpl::int_&lt;3&gt;)       { return _v3; }
<span class="lineNum">     209 </span>                :     typename element_const_reference_type&lt;homogeneous_color_base&gt;::type at(mpl::int_&lt;3&gt;) const { return _v3; }
<span class="lineNum">     210 </span>                :     homogeneous_color_base() {}
<span class="lineNum">     211 </span>                :     explicit homogeneous_color_base(Element v) : _v0(v), _v1(v), _v2(v), _v3(v) {}
<span class="lineNum">     212 </span>                :     homogeneous_color_base(Element v0, Element v1, Element v2, Element v3) : _v0(v0), _v1(v1), _v2(v2), _v3(v3) {}
<span class="lineNum">     213 </span>                : 
<span class="lineNum">     214 </span>                :     template &lt;typename E2, typename L2&gt; homogeneous_color_base(const homogeneous_color_base&lt;E2,L2,4&gt;&amp; c) :
<span class="lineNum">     215 </span>                :         _v0(at_c&lt;mapping_transform&lt;Layout,L2,0&gt;::value&gt;(c)), 
<span class="lineNum">     216 </span>                :         _v1(at_c&lt;mapping_transform&lt;Layout,L2,1&gt;::value&gt;(c)), 
<span class="lineNum">     217 </span>                :         _v2(at_c&lt;mapping_transform&lt;Layout,L2,2&gt;::value&gt;(c)),
<span class="lineNum">     218 </span>                :         _v3(at_c&lt;mapping_transform&lt;Layout,L2,3&gt;::value&gt;(c)) {}
<span class="lineNum">     219 </span>                : 
<span class="lineNum">     220 </span>                :     // Support for l-value reference proxy copy construction
<span class="lineNum">     221 </span>                :     template &lt;typename E2, typename L2&gt; homogeneous_color_base(      homogeneous_color_base&lt;E2,L2,4&gt;&amp; c) : 
<span class="lineNum">     222 </span>                :         _v0(at_c&lt;mapping_transform&lt;Layout,L2,0&gt;::value&gt;(c)), 
<span class="lineNum">     223 </span>                :         _v1(at_c&lt;mapping_transform&lt;Layout,L2,1&gt;::value&gt;(c)), 
<span class="lineNum">     224 </span>                :         _v2(at_c&lt;mapping_transform&lt;Layout,L2,2&gt;::value&gt;(c)),
<span class="lineNum">     225 </span>                :         _v3(at_c&lt;mapping_transform&lt;Layout,L2,3&gt;::value&gt;(c)) {}
<span class="lineNum">     226 </span>                : 
<span class="lineNum">     227 </span>                :     // Support for planar_pixel_iterator construction and dereferencing
<span class="lineNum">     228 </span>                :     template &lt;typename P&gt; homogeneous_color_base(P* p,bool) : 
<span class="lineNum">     229 </span>                :         _v0(&amp;semantic_at_c&lt;0&gt;(*p)), 
<span class="lineNum">     230 </span>                :         _v1(&amp;semantic_at_c&lt;1&gt;(*p)), 
<span class="lineNum">     231 </span>                :         _v2(&amp;semantic_at_c&lt;2&gt;(*p)), 
<span class="lineNum">     232 </span>                :         _v3(&amp;semantic_at_c&lt;3&gt;(*p)) {}
<span class="lineNum">     233 </span>                : 
<span class="lineNum">     234 </span>                :     template &lt;typename Ref&gt; Ref deref() const { 
<span class="lineNum">     235 </span>                :         return Ref(*semantic_at_c&lt;0&gt;(*this), 
<span class="lineNum">     236 </span>                :                    *semantic_at_c&lt;1&gt;(*this), 
<span class="lineNum">     237 </span>                :                    *semantic_at_c&lt;2&gt;(*this), 
<span class="lineNum">     238 </span>                :                    *semantic_at_c&lt;3&gt;(*this)); }
<span class="lineNum">     239 </span>                : 
<span class="lineNum">     240 </span>                :     // Support for planar_pixel_reference offset constructor
<span class="lineNum">     241 </span>                :     template &lt;typename Ptr&gt; homogeneous_color_base(const Ptr&amp; ptr, std::ptrdiff_t diff) 
<span class="lineNum">     242 </span>                :         : _v0(*memunit_advanced(semantic_at_c&lt;0&gt;(ptr),diff)),
<span class="lineNum">     243 </span>                :           _v1(*memunit_advanced(semantic_at_c&lt;1&gt;(ptr),diff)),
<span class="lineNum">     244 </span>                :           _v2(*memunit_advanced(semantic_at_c&lt;2&gt;(ptr),diff)),
<span class="lineNum">     245 </span>                :           _v3(*memunit_advanced(semantic_at_c&lt;3&gt;(ptr),diff)) {}
<span class="lineNum">     246 </span>                : 
<span class="lineNum">     247 </span>                :     // Support for planar_pixel_reference operator[]
<span class="lineNum">     248 </span>                :     Element at_c_dynamic(std::size_t i) const {
<span class="lineNum">     249 </span>                :         switch (i) {
<span class="lineNum">     250 </span>                :             case 0: return _v0;
<span class="lineNum">     251 </span>                :             case 1: return _v1;
<span class="lineNum">     252 </span>                :             case 2: return _v2;
<span class="lineNum">     253 </span>                :         }
<span class="lineNum">     254 </span>                :         return _v3;
<span class="lineNum">     255 </span>                :     }
<span class="lineNum">     256 </span>                : };
<span class="lineNum">     257 </span>                : 
<span class="lineNum">     258 </span>                : /// \brief A homogeneous color base holding five color elements. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept
<span class="lineNum">     259 </span>                : /// \ingroup ColorBaseModelHomogeneous
<span class="lineNum">     260 </span>                : template &lt;typename Element, typename Layout&gt;
<span class="lineNum">     261 </span>                : struct homogeneous_color_base&lt;Element,Layout,5&gt; {
<span class="lineNum">     262 </span>                : private:
<span class="lineNum">     263 </span>                :     Element _v0, _v1, _v2, _v3, _v4;
<span class="lineNum">     264 </span>                : public:
<span class="lineNum">     265 </span>                :     typedef Layout layout_t;
<span class="lineNum">     266 </span>                :     typename element_reference_type&lt;homogeneous_color_base&gt;::type       at(mpl::int_&lt;0&gt;)       { return _v0; }
<span class="lineNum">     267 </span>                :     typename element_const_reference_type&lt;homogeneous_color_base&gt;::type at(mpl::int_&lt;0&gt;) const { return _v0; }
<span class="lineNum">     268 </span>                :     typename element_reference_type&lt;homogeneous_color_base&gt;::type       at(mpl::int_&lt;1&gt;)       { return _v1; }
<span class="lineNum">     269 </span>                :     typename element_const_reference_type&lt;homogeneous_color_base&gt;::type at(mpl::int_&lt;1&gt;) const { return _v1; }
<span class="lineNum">     270 </span>                :     typename element_reference_type&lt;homogeneous_color_base&gt;::type       at(mpl::int_&lt;2&gt;)       { return _v2; }
<span class="lineNum">     271 </span>                :     typename element_const_reference_type&lt;homogeneous_color_base&gt;::type at(mpl::int_&lt;2&gt;) const { return _v2; }
<span class="lineNum">     272 </span>                :     typename element_reference_type&lt;homogeneous_color_base&gt;::type       at(mpl::int_&lt;3&gt;)       { return _v3; }
<span class="lineNum">     273 </span>                :     typename element_const_reference_type&lt;homogeneous_color_base&gt;::type at(mpl::int_&lt;3&gt;) const { return _v3; }
<span class="lineNum">     274 </span>                :     typename element_reference_type&lt;homogeneous_color_base&gt;::type       at(mpl::int_&lt;4&gt;)       { return _v4; }
<span class="lineNum">     275 </span>                :     typename element_const_reference_type&lt;homogeneous_color_base&gt;::type at(mpl::int_&lt;4&gt;) const { return _v4; }
<span class="lineNum">     276 </span>                :     homogeneous_color_base() {}
<span class="lineNum">     277 </span>                :     explicit homogeneous_color_base(Element v) : _v0(v), _v1(v), _v2(v), _v3(v), _v4(v) {}
<span class="lineNum">     278 </span>                :     homogeneous_color_base(Element v0, Element v1, Element v2, Element v3, Element v4) : _v0(v0), _v1(v1), _v2(v2), _v3(v3), _v4(v4) {}
<span class="lineNum">     279 </span>                : 
<span class="lineNum">     280 </span>                :     template &lt;typename E2, typename L2&gt; homogeneous_color_base(const homogeneous_color_base&lt;E2,L2,5&gt;&amp; c) :
<span class="lineNum">     281 </span>                :         _v0(at_c&lt;mapping_transform&lt;Layout,L2,0&gt;::value&gt;(c)), 
<span class="lineNum">     282 </span>                :         _v1(at_c&lt;mapping_transform&lt;Layout,L2,1&gt;::value&gt;(c)), 
<span class="lineNum">     283 </span>                :         _v2(at_c&lt;mapping_transform&lt;Layout,L2,2&gt;::value&gt;(c)),
<span class="lineNum">     284 </span>                :         _v3(at_c&lt;mapping_transform&lt;Layout,L2,3&gt;::value&gt;(c)),
<span class="lineNum">     285 </span>                :         _v4(at_c&lt;mapping_transform&lt;Layout,L2,4&gt;::value&gt;(c)) {}
<span class="lineNum">     286 </span>                : 
<span class="lineNum">     287 </span>                :     // Support for l-value reference proxy copy construction
<span class="lineNum">     288 </span>                :     template &lt;typename E2, typename L2&gt; homogeneous_color_base(      homogeneous_color_base&lt;E2,L2,5&gt;&amp; c) : 
<span class="lineNum">     289 </span>                :         _v0(at_c&lt;mapping_transform&lt;Layout,L2,0&gt;::value&gt;(c)), 
<span class="lineNum">     290 </span>                :         _v1(at_c&lt;mapping_transform&lt;Layout,L2,1&gt;::value&gt;(c)), 
<span class="lineNum">     291 </span>                :         _v2(at_c&lt;mapping_transform&lt;Layout,L2,2&gt;::value&gt;(c)),
<span class="lineNum">     292 </span>                :         _v3(at_c&lt;mapping_transform&lt;Layout,L2,3&gt;::value&gt;(c)),
<span class="lineNum">     293 </span>                :         _v4(at_c&lt;mapping_transform&lt;Layout,L2,4&gt;::value&gt;(c)) {}
<span class="lineNum">     294 </span>                : 
<span class="lineNum">     295 </span>                :     // Support for planar_pixel_iterator construction and dereferencing
<span class="lineNum">     296 </span>                :     template &lt;typename P&gt; homogeneous_color_base(P* p,bool) : 
<span class="lineNum">     297 </span>                :         _v0(&amp;semantic_at_c&lt;0&gt;(*p)), 
<span class="lineNum">     298 </span>                :         _v1(&amp;semantic_at_c&lt;1&gt;(*p)), 
<span class="lineNum">     299 </span>                :         _v2(&amp;semantic_at_c&lt;2&gt;(*p)), 
<span class="lineNum">     300 </span>                :         _v3(&amp;semantic_at_c&lt;3&gt;(*p)),
<span class="lineNum">     301 </span>                :         _v4(&amp;semantic_at_c&lt;4&gt;(*p)) {}
<span class="lineNum">     302 </span>                : 
<span class="lineNum">     303 </span>                :     template &lt;typename Ref&gt; Ref deref() const { 
<span class="lineNum">     304 </span>                :         return Ref(*semantic_at_c&lt;0&gt;(*this), 
<span class="lineNum">     305 </span>                :                    *semantic_at_c&lt;1&gt;(*this), 
<span class="lineNum">     306 </span>                :                    *semantic_at_c&lt;2&gt;(*this), 
<span class="lineNum">     307 </span>                :                    *semantic_at_c&lt;3&gt;(*this),
<span class="lineNum">     308 </span>                :                    *semantic_at_c&lt;4&gt;(*this)); }
<span class="lineNum">     309 </span>                : 
<span class="lineNum">     310 </span>                :     // Support for planar_pixel_reference offset constructor
<span class="lineNum">     311 </span>                :     template &lt;typename Ptr&gt; homogeneous_color_base(const Ptr&amp; ptr, std::ptrdiff_t diff) 
<span class="lineNum">     312 </span>                :         : _v0(*memunit_advanced(semantic_at_c&lt;0&gt;(ptr),diff)),
<span class="lineNum">     313 </span>                :           _v1(*memunit_advanced(semantic_at_c&lt;1&gt;(ptr),diff)),
<span class="lineNum">     314 </span>                :           _v2(*memunit_advanced(semantic_at_c&lt;2&gt;(ptr),diff)),
<span class="lineNum">     315 </span>                :           _v3(*memunit_advanced(semantic_at_c&lt;3&gt;(ptr),diff)),
<span class="lineNum">     316 </span>                :           _v4(*memunit_advanced(semantic_at_c&lt;4&gt;(ptr),diff)) {}
<span class="lineNum">     317 </span>                : 
<span class="lineNum">     318 </span>                :     // Support for planar_pixel_reference operator[]
<span class="lineNum">     319 </span>                :     Element at_c_dynamic(std::size_t i) const {
<span class="lineNum">     320 </span>                :         switch (i) {
<span class="lineNum">     321 </span>                :             case 0: return _v0;
<span class="lineNum">     322 </span>                :             case 1: return _v1;
<span class="lineNum">     323 </span>                :             case 2: return _v2;
<span class="lineNum">     324 </span>                :             case 3: return _v3;
<span class="lineNum">     325 </span>                :         }
<span class="lineNum">     326 </span>                :         return _v4;
<span class="lineNum">     327 </span>                :     }
<span class="lineNum">     328 </span>                : };
<span class="lineNum">     329 </span>                : 
<span class="lineNum">     330 </span>                : // The following way of casting adjacent channels (the contents of color_base) into an array appears to be unsafe
<span class="lineNum">     331 </span>                : // -- there is no guarantee that the compiler won't add any padding between adjacent channels.
<span class="lineNum">     332 </span>                : // Note, however, that GIL _must_ be compiled with compiler settings ensuring there is no padding in the color base structs.
<span class="lineNum">     333 </span>                : // This is because the color base structs must model the interleaved organization in memory. In other words, the client may
<span class="lineNum">     334 </span>                : // have existing RGB image in the form &quot;RGBRGBRGB...&quot; and we must be able to represent it with an array of RGB color bases (i.e. RGB pixels)
<span class="lineNum">     335 </span>                : // with no padding. We have tested with char/int/float/double channels on gcc and VC and have so far discovered no problem.
<span class="lineNum">     336 </span>                : // We have even tried using strange channels consisting of short + char (3 bytes). With the default 4-byte alignment on VC, the size
<span class="lineNum">     337 </span>                : // of this channel is padded to 4 bytes, so an RGB pixel of it will be 4x3=12 bytes. The code below will still work properly.
<span class="lineNum">     338 </span>                : // However, the client must nevertheless ensure that proper compiler settings are used for their compiler and their channel types.
<span class="lineNum">     339 </span>                : 
<span class="lineNum">     340 </span>                : template &lt;typename Element, typename Layout, int K&gt;
<span class="lineNum">     341 </span>                : typename element_reference_type&lt;homogeneous_color_base&lt;Element,Layout,K&gt; &gt;::type       
<span class="lineNum">     342 </span>                : dynamic_at_c(homogeneous_color_base&lt;Element,Layout,K&gt;&amp; cb, std::size_t i) {
<span class="lineNum">     343 </span>                :     assert(i&lt;K);
<span class="lineNum">     344 </span>                :     return (gil_reinterpret_cast&lt;Element*&gt;(&amp;cb))[i];
<span class="lineNum">     345 </span>                : }
<span class="lineNum">     346 </span>                : 
<span class="lineNum">     347 </span>                : template &lt;typename Element, typename Layout, int K&gt;
<span class="lineNum">     348 </span>                : typename element_const_reference_type&lt;homogeneous_color_base&lt;Element,Layout,K&gt; &gt;::type 
<span class="lineNum">     349 </span>                : dynamic_at_c(const homogeneous_color_base&lt;Element,Layout,K&gt;&amp; cb, std::size_t i) {
<span class="lineNum">     350 </span>                :     assert(i&lt;K);
<span class="lineNum">     351 </span>                :     return (gil_reinterpret_cast_c&lt;const Element*&gt;(&amp;cb))[i];
<span class="lineNum">     352 </span>                : }
<span class="lineNum">     353 </span>                : 
<span class="lineNum">     354 </span>                : template &lt;typename Element, typename Layout, int K&gt;
<span class="lineNum">     355 </span>                : typename element_reference_type&lt;homogeneous_color_base&lt;Element&amp;,Layout,K&gt; &gt;::type       
<span class="lineNum">     356 </span>                : dynamic_at_c(const homogeneous_color_base&lt;Element&amp;,Layout,K&gt;&amp; cb, std::size_t i) {
<span class="lineNum">     357 </span>                :     assert(i&lt;K);
<span class="lineNum">     358 </span>                :     return cb.at_c_dynamic(i);
<span class="lineNum">     359 </span>                : }
<span class="lineNum">     360 </span>                : 
<span class="lineNum">     361 </span>                : template &lt;typename Element, typename Layout, int K&gt;
<span class="lineNum">     362 </span>                : typename element_const_reference_type&lt;homogeneous_color_base&lt;const Element&amp;,Layout,K&gt; &gt;::type 
<span class="lineNum">     363 </span>                : dynamic_at_c(const homogeneous_color_base&lt;const Element&amp;,Layout,K&gt;&amp; cb, std::size_t i) {
<span class="lineNum">     364 </span>                :     assert(i&lt;K);
<span class="lineNum">     365 </span>                :     return cb.at_c_dynamic(i);
<span class="lineNum">     366 </span>                : }
<span class="lineNum">     367 </span>                : 
<span class="lineNum">     368 </span>                : 
<span class="lineNum">     369 </span>                : } // namespace detail
<span class="lineNum">     370 </span>                : 
<span class="lineNum">     371 </span>                : template &lt;typename Element, typename Layout, int K1, int K&gt;  
<span class="lineNum">     372 </span>                : struct kth_element_type&lt;detail::homogeneous_color_base&lt;Element,Layout,K1&gt;, K&gt; {
<span class="lineNum">     373 </span>                :     typedef Element type;
<span class="lineNum">     374 </span>                : };
<span class="lineNum">     375 </span>                : 
<span class="lineNum">     376 </span>                : template &lt;typename Element, typename Layout, int K1, int K&gt; 
<span class="lineNum">     377 </span>                : struct kth_element_reference_type&lt;detail::homogeneous_color_base&lt;Element,Layout,K1&gt;, K&gt; : public add_reference&lt;Element&gt; {};
<span class="lineNum">     378 </span>                : 
<span class="lineNum">     379 </span>                : template &lt;typename Element, typename Layout, int K1, int K&gt; 
<span class="lineNum">     380 </span>                : struct kth_element_const_reference_type&lt;detail::homogeneous_color_base&lt;Element,Layout,K1&gt;, K&gt; : public add_reference&lt;typename add_const&lt;Element&gt;::type&gt; {};
<span class="lineNum">     381 </span>                : 
<span class="lineNum">     382 </span>                : /// \brief Provides mutable access to the K-th element, in physical order
<span class="lineNum">     383 </span>                : /// \ingroup ColorBaseModelHomogeneous
<span class="lineNum">     384 </span>                : template &lt;int K, typename E, typename L, int N&gt; inline
<span class="lineNum">     385 </span>                : typename add_reference&lt;E&gt;::type
<span class="lineNum">     386 </span><span class="lineCov">         428796 : at_c(      detail::homogeneous_color_base&lt;E,L,N&gt;&amp; p) { return p.at(mpl::int_&lt;K&gt;()); }</span>
<span class="lineNum">     387 </span>                : 
<span class="lineNum">     388 </span>                : /// \brief Provides constant access to the K-th element, in physical order
<span class="lineNum">     389 </span>                : /// \ingroup ColorBaseModelHomogeneous
<span class="lineNum">     390 </span>                : template &lt;int K, typename E, typename L, int N&gt; inline
<span class="lineNum">     391 </span>                : typename add_reference&lt;typename add_const&lt;E&gt;::type&gt;::type
<span class="lineNum">     392 </span><span class="lineCov">         428796 : at_c(const detail::homogeneous_color_base&lt;E,L,N&gt;&amp; p) { return p.at(mpl::int_&lt;K&gt;()); }</span>
<span class="lineNum">     393 </span>                : 
<span class="lineNum">     394 </span>                : namespace detail {
<span class="lineNum">     395 </span>                :     struct swap_fn {
<span class="lineNum">     396 </span>                :         template &lt;typename T&gt; void operator()(T&amp; x, T&amp; y) const {
<span class="lineNum">     397 </span>                :             using std::swap;
<span class="lineNum">     398 </span>                :             swap(x,y);
<span class="lineNum">     399 </span>                :         }
<span class="lineNum">     400 </span>                :     };
<span class="lineNum">     401 </span>                : }
<span class="lineNum">     402 </span>                : template &lt;typename E, typename L, int N&gt; inline
<span class="lineNum">     403 </span>                : void swap(detail::homogeneous_color_base&lt;E,L,N&gt;&amp; x, detail::homogeneous_color_base&lt;E,L,N&gt;&amp; y) { 
<span class="lineNum">     404 </span>                :     static_for_each(x,y,detail::swap_fn());
<span class="lineNum">     405 </span>                : }
<span class="lineNum">     406 </span>                : 
<span class="lineNum">     407 </span>                : 
<span class="lineNum">     408 </span>                : } }  // namespace boost::gil
<span class="lineNum">     409 </span>                : 
<span class="lineNum">     410 </span>                : #endif
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
